﻿cmake_minimum_required(VERSION 3.5)

project(QtDeigtalPhotoProcess LANGUAGES CXX)

set(CMAKE_INCLUDE_CURRENT_DIR ON)

set(CMAKE_AUTOUIC ON)
set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTORCC ON)

set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

# 如果是 MSVC 编译器，添加 /utf-8 选项
if(MSVC)
    add_compile_options(/utf-8)
    message(STATUS "MSVC compiler detected, added /utf-8 option")
endif()

# 查找Qt需要包
find_package(Qt5 COMPONENTS Widgets REQUIRED)
# 查找OpenCV需要的包
find_package(OpenCV REQUIRED)
# 输出OpenCV版本信息用于调试
message(STATUS "OpenCV version: ${OpenCV_VERSION}")
message(STATUS "OpenCV libraries: ${OpenCV_LIBS}")

# 使用SIMD指令
# 添加SIMD头文件目录
set(SIMD_DIR "E:/1QtPrj/QtOpenCV/QtDeigtalPhotoProcess/SIMD")
message(STATUS "SIMD: ${SIMD_DIR}")
# 如果您需要根据CPU特性选择不同的实现
option(ENABLE_SIMD "Enable SIMD optimizations" ON)
if(ENABLE_SIMD)
    add_definitions(-DUSE_SIMD)
    message(STATUS "SIMD optimizations enabled")
endif()

if(ANDROID)
  add_library(QtDeigtalPhotoProcess SHARED
    main.cpp
    MyGraphicsView.cpp
    MyGraphicsView.h
    MyComBox.cpp
    MyComBox.h
    CImgEnhance.cpp
    CImgEnhance.h
    widget.cpp
    widget.h
    widget.ui
    SIMD/vectorclass.h # 添加SIMD头文件，#include该头文件，其他的会自动包含
  )
else()
  add_executable(QtDeigtalPhotoProcess
    main.cpp
    MyGraphicsView.cpp
    MyGraphicsView.h
    MyComBox.cpp
    MyComBox.h
    CImgEnhance.cpp
    CImgEnhance.h
    widget.cpp
    widget.h
    widget.ui
  )
endif()

target_link_libraries(QtDeigtalPhotoProcess PRIVATE
    Qt5::Widgets
    ${OpenCV_LIBS}  # 链接OpenCV库
)

# 包含OpenCV头文件目录
target_include_directories(QtDeigtalPhotoProcess PRIVATE ${OpenCV_INCLUDE_DIRS})
# 显式包含SIMD头文件目录
target_include_directories(QtDeigtalPhotoProcess PRIVATE ${SIMD_DIR})


